import Mock from 'mockjs'

const data = Mock.mock({
  "banners|5": ["@image(375x200, @color, banner)"],
  "list|10": [{
    "image": "@image(120x80, @color, itme)",
    "id": "@id",
    "title": "@ctitle",
    "desc": '@cword(10, 20)',
    "price|10-1000": 1
  }]
})

Mock.mock('/api/banners', {
  "code": 200,
  "message": 'ok',
  "data": data.banners
})

Mock.mock('/api/lists', {
  "code": 200,
  "message": 'ok',
  "data": data.list
})

Mock.mock('/api/list', 'post', (options: any) => {
  const { id } = JSON.parse(options.body)
  return {
    "code": 200,
    "message": 'ok',
    "data": data.list.find((v: any) => v.id === id)
  }
})
